package chapter07;

/**
 * Created by Miracle yaochengwei on 2022/6/21 9:19
 */
public class MethodParameter01 {
     static class AA {
        public void swap(int a, int b) {
            System.out.println("\na 和 b 交换前的值\na=" + a + "\tb=" + b);//a=10 b=20
            //完成了 a  和 b 的交换
            int tmp = a;
            a = b;
            b = tmp;
            System.out.println("\na 和 b 交换后的值\na=" + a + "\tb=" + b);//a=20 b=10
        }
    }

    public static void main(String[] args) {
    int a =10;
    int b = 20;
    //创建AA对象
        AA obj = new AA();
        obj.swap(a,b);//把上面的a和b 传给 swap的a  b
        System.out.println("main方法 a=" + a + " b=" + b);//a=10 b=20
    }
}
